<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="BgColor.css" type="text/css">
    <title>Document</title>
</head>
<body>
        <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <div id="app">
       <div :class="clsProp">
       <h1>abc</h1> 
        </div>
    </div>
    <script>
        var app=new Vue({
            el:'#app',       
            data:{
              hasColor:true,
              hasNum:false,
              colorCls:"forecolor"
            },
            computed:{
                bgColorCls:function() {
                    return this.hasColor?'bgcolor':''
                },
               clsProp:function(){
                   return{
                       bgcolor:this.hasColor,
                       forecolor:this.hasNum
                   }
               }
            }
        })
    </script>
</body>
</html>